package c.x.jy.wexin.controller;

import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.StudiesEntity;
import c.x.jy.service.service.StudiesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


/**
 * 
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-06-18 19:50:27
 */
@RestController
@RequestMapping("wechat/studies")
public class StudiesController  {
    @Autowired
    private StudiesService studiesService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = studiesService.queryPage(params);

        return R.put(page);
    }


    @RequestMapping("/all")

    public R all(){
        List<StudiesEntity> page = studiesService.all();

        return R.put(page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:studies:info")
    public R info(@PathVariable("id") Long id){
		StudiesEntity studies = studiesService.getById(id);

        return R.put(studies);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:studies:save")
    public R save(@RequestBody StudiesEntity studies){
		studiesService.save(studies);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:studies:update")
    public R update(@RequestBody StudiesEntity studies){
		studiesService.updateById(studies);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("sys:studies:delete")
    public R delete(@PathVariable("id") Long id){
		studiesService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

